package com.lsw.jgyf.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.lsw.Base.BaseHolder;
import com.lsw.Base.BaseSimpleAdapter;
import com.lsw.jgyf.R;
import com.lsw.jgyf.model.MoreOptionsModel;

import java.util.List;

/**
 * Created by lsw on 2018/7/11.
 */

public class MoreOptionsAdapter extends BaseSimpleAdapter<MoreOptionsModel> {
    public MoreOptionsAdapter(Context context) {
        super(context);
    }

    @Override
    protected BaseHolder<MoreOptionsModel> getHolder() {
        return new BaseHolder<MoreOptionsModel>() {
            TextView tv_gongsi_name;
            TextView tv_chanpin_name;
            TextView tv_yuegong;
            TextView tv_shoufu;
            TextView tv_qishu;
            TextView tv_seclect;

            @Override
            public void bindViews(View parentView) {
                tv_gongsi_name = parentView.findViewById(R.id.tv_gongsi_name);
                tv_chanpin_name = parentView.findViewById(R.id.tv_chanpin_name);
                tv_yuegong = parentView.findViewById(R.id.tv_yuegong);
                tv_shoufu = parentView.findViewById(R.id.tv_shoufu);
                tv_qishu = parentView.findViewById(R.id.tv_qishu);
                tv_seclect = parentView.findViewById(R.id.tv_seclect);

            }

            @Override
            public void bindData(MoreOptionsModel item, int position) {
                tv_gongsi_name.setText(item.getCompany_name());
                tv_chanpin_name.setText(item.getCompany_product_name());
                tv_yuegong.setText(item.getMonthly_supply() + "");
                tv_shoufu.setText(item.getFirst_money());
                tv_qishu.setText(item.getPeriods() + "");
                if (item.isIs_cooperation()) {
                    tv_seclect.setText("选择");
                } else {
                    tv_seclect.setText("未签约");
                }
                tv_seclect.setOnClickListener(v -> {
                    if (!item.isIs_cooperation())
                        return;
                    if (adapterRefresh != null)
                        adapterRefresh.onRefreshAdapter(position, 1);
                });
            }
        };
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.item_more_options;
    }
}
